cmake_minimum_required(VERSION 3.16)

project(LitterPutting VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 查找Qt6组件，包括3D渲染支持
# 注意：MinGW 版本的 Qt 不支持 WebEngine，使用纯 QML 太阳系
find_package(Qt6 REQUIRED COMPONENTS 
    Quick 
    Qml 
    QuickControls2 
    Quick3D 
    Network
    Multimedia
)

qt_standard_project_setup(REQUIRES 6.9)

# 确保资源文件被处理
qt_add_resources(appLitterPutting_QRC qml.qrc)

# 可执行程序
qt_add_executable(appLitterPutting
    main.cpp
    Skill.h
    SkillModel.cpp
    SkillModel.h
    SolarSystemModel.h
    SolarSystemModel.cpp
    MountainRecordModel.h
    MountainRecordModel.cpp
    PlayerProfile.h
    PlayerModel.h
    PlayerModel.cpp
    HeightRecord.h
    HeightRecordModel.h
    HeightRecordModel.cpp
    ${appLitterPutting_QRC} # 确保资源被编译进来
)

# Windows平台图标配置
if(WIN32)
    target_sources(appLitterPutting PRIVATE appicon.rc)
endif()

# QML 模块 (注释掉避免和手动资源冲突)
# qt_add_qml_module(appLitterPutting
#     URI LitterPutting
#     VERSION 1.0
# )
set_target_properties(appLitterPutting PROPERTIES
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

# Android特定配置
if(ANDROID)
    set_target_properties(appLitterPutting PROPERTIES
        QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android"
        QT_ANDROID_MIN_SDK_VERSION 28
        QT_ANDROID_TARGET_SDK_VERSION 33
    )
endif()

target_link_libraries(appLitterPutting
    PRIVATE
        Qt6::Quick
        Qt6::Qml
        Qt6::QuickControls2
        Qt6::Quick3D
        Qt6::Network
        Qt6::Multimedia
)

include(GNUInstallDirs)
install(TARGETS appLitterPutting
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
